//
// Created by Administrator on 2016/9/2.
//

#ifndef PROJECT_SHAREHEADERS_H
#define PROJECT_SHAREHEADERS_H

//GLEW, If you want to use GLEW via their static library we have to define a pre-processor variable GLEW_STATIC before including GLEW.
#define GLEW_STATIC

#include <GL/glew.h>

//SDL
#include <SDL/SDL.h>

//GLM(GL Mathematic)
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/vector_angle.hpp>

#include <iostream>
#include <string>
#include <vector>

//assimp
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/material.h>
#include <assimp/postprocess.h>

//SOIL
#include <SOIL/SOIL.h>

#include <ZainTL.h>

#include <unordered_map>

namespace ZainGL {
    extern glm::vec3 WORLD_UP;

    struct Texture {
        GLuint textureID;
        aiTextureType type;
        std::string path;
    };

    /*Textures*/
    Texture *loadTexture(const char *path, std::unordered_map<std::string, ZainTL::FileDatas> *bufferMap = nullptr);

    Texture *loadCubeMap(const char *right, const char *left, const char *top, const char *bottom, const char *back,
                         const char *front, std::unordered_map<std::string, ZainTL::FileDatas> *bufferMap = nullptr);

    /*Shaders*/
    const GLchar *getFileText(const GLchar *path);

    //************************************
    // Parameter: int mouseX  Mouse position, in pixels, from bottom-left corner of the window
    // Parameter: int mouseY
    // Parameter: int screenWidth Window size, in pixels
    // Parameter: int screenHeight
    // Parameter: glm::mat4 ViewMatrix    CameraView Matrix
    // Parameter: glm::mat4 ProjectionMatrix     Camera parameters (ratio, field of view, near and far planes)
    // Parameter: glm::vec3 & out_origin         Ouput : Origin of the ray. /!\ Starts at the near plane, so if you want the ray to start at the camera's position instead, ignore this.
    // Parameter: glm::vec3 & out_direction     Ouput : Direction, in world space, of the ray that goes "through" the mouse.
    void screenPosToWorldRay(int32_t mouseX, int32_t mouseY, uint32_t screenWidth, uint32_t screenHeight,
                             glm::mat4 viewMatrix,
                             glm::mat4 projectionMatrix, glm::vec3 &outOrigin, glm::vec3 &outDirection);
}

#endif //PROJECT_SHAREHEADERS_H
